/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controler.formbeans;

import javax.servlet.http.HttpServletRequest;
import model.pojo.Vacancies;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.upload.FormFile;

/**
 *
 * @author maha
 */
public class ApplicantBean extends org.apache.struts.action.ActionForm {

    private double userId;
    private String firstName;
    private String middleName;
    private String lastName;
    private String gender;
    private String bd;
    private int placeOfBirth;
    private String maritalStatus;
    private String militaryStatus;
    private String add1;
    private String add2;
    private String country;
    private String city;
    private String zipCode;
    private String phone;
    private String mob;
    private int levOfEd;
    private int university;
    private String gradYear;
    private int grad;
    private int fieldOfStudy;
    private int yearsOfExp;
    private int career;
    private FormFile cvPath;
    private int children;
    private String compName1;
    private String pos1;
    private String compName2;
    private String pos2;
    private String compName3;
    private String pos3;
    private String from1;
    private String from2;
    private String from3;
    private String to1;
    private String to2;
    private String to3;
    private String natid;
    private String message;
    private Integer vacancyId;
    private String vacancyTitle;
    private String positionType;
    private Integer availableVacancyNumber;
    private String deadline;
    private String refrence;
    private String description;
    private String departmentId;
    private String showVacancy;

    public Integer getVacancyId() {
        return vacancyId;
    }

    public void setVacancyId(Integer vacancyId) {
        this.vacancyId = vacancyId;
    }

    public String getVacancyTitle() {
        return vacancyTitle;
    }

    public void setVacancyTitle(String vacancyTitle) {
        this.vacancyTitle = vacancyTitle;
    }

    public String getPositionType() {
        return positionType;
    }

    public void setPositionType(String positionType) {
        this.positionType = positionType;
    }

    public Integer getAvailableVacancyNumber() {
        return availableVacancyNumber;
    }

    public void setAvailableVacancyNumber(Integer availableVacancyNumber) {
        this.availableVacancyNumber = availableVacancyNumber;
    }

    public String getDeadline() {
        return deadline;
    }

    public void setDeadline(String deadline) {
        this.deadline = deadline;
    }

    public String getRefrence() {
        return refrence;
    }

    public void setRefrence(String refrence) {
        this.refrence = refrence;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getShowVacancy() {
        return showVacancy;
    }

    public void setShowVacancy(String showVacancy) {
        this.showVacancy = showVacancy;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMilitaryStatus() {
        return militaryStatus;
    }

    public void setMilitaryStatus(String militaryStatus) {
        this.militaryStatus = militaryStatus;
    }

    public ApplicantBean() {
        super();
    }

    public String getGradYear() {
        return gradYear;
    }

    public void setGradYear(String gradYear) {
        this.gradYear = gradYear;
    }

    public String getNatid() {
        return natid;
    }

    public void setNatid(String natid) {
        this.natid = natid;
    }

    public double getUserId() {
        return userId;
    }

    public int getGrad() {
        return grad;
    }

    public void setGrad(int grad) {
        this.grad = grad;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public void setUserId(double userId) {
        this.userId = userId;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        this.middleName = middleName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getBd() {
        return bd;
    }

    public void setBd(String bd) {
        this.bd = bd;
    }

    public int getPlaceOfBirth() {
        return placeOfBirth;
    }

    public void setPlaceOfBirth(int placeOfBirth) {
        this.placeOfBirth = placeOfBirth;
    }

    public String getMaritalStatus() {
        return maritalStatus;
    }

    public void setMaritalStatus(String maritalStatus) {
        this.maritalStatus = maritalStatus;
    }

    public String getAdd1() {
        return add1;
    }

    public void setAdd1(String add1) {
        this.add1 = add1;
    }

    public String getAdd2() {
        return add2;
    }

    public void setAdd2(String add2) {
        this.add2 = add2;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getMob() {
        return mob;
    }

    public void setMob(String mob) {
        this.mob = mob;
    }

    public int getLevOfEd() {
        return levOfEd;
    }

    public void setLevOfEd(int levOfEd) {
        this.levOfEd = levOfEd;
    }

    public int getUniversity() {
        return university;
    }

    public void setUniversity(int university) {
        this.university = university;
    }

    public int getFieldOfStudy() {
        return fieldOfStudy;
    }

    public void setFieldOfStudy(int fieldOfStudy) {
        this.fieldOfStudy = fieldOfStudy;
    }

    public int getYearsOfExp() {
        return yearsOfExp;
    }

    public void setYearsOfExp(int yearsOfExp) {
        this.yearsOfExp = yearsOfExp;
    }

    public int getCareer() {
        return career;
    }

    public void setCareer(int career) {
        this.career = career;
    }

    public FormFile getCvPath() {
        return cvPath;
    }

    public void setCvPath(FormFile cvPath) {
        this.cvPath = cvPath;
    }

    public int getChildren() {
        return children;
    }

    public void setChildren(int children) {
        this.children = children;
    }

    public String getCompName1() {
        return compName1;
    }

    public void setCompName1(String compName1) {
        this.compName1 = compName1;
    }

    public String getPos1() {
        return pos1;
    }

    public void setPos1(String pos1) {
        this.pos1 = pos1;
    }

    public String getCompName2() {
        return compName2;
    }

    public void setCompName2(String compName2) {
        this.compName2 = compName2;
    }

    public String getPos2() {
        return pos2;
    }

    public void setPos2(String pos2) {
        this.pos2 = pos2;
    }

    public String getCompName3() {
        return compName3;
    }

    public void setCompName3(String compName3) {
        this.compName3 = compName3;
    }

    public String getPos3() {
        return pos3;
    }

    public void setPos3(String pos3) {
        this.pos3 = pos3;
    }

    public String getFrom1() {
        return from1;
    }

    public void setFrom1(String from1) {
        this.from1 = from1;
    }

    public String getFrom2() {
        return from2;
    }

    public void setFrom2(String from2) {
        this.from2 = from2;
    }

    public String getFrom3() {
        return from3;
    }

    public void setFrom3(String from3) {
        this.from3 = from3;
    }

    public String getTo1() {
        return to1;
    }

    public void setTo1(String to1) {
        this.to1 = to1;
    }

    public String getTo2() {
        return to2;
    }

    public void setTo2(String to2) {
        this.to2 = to2;
    }

    public String getTo3() {
        return to3;
    }

    public void setTo3(String to3) {
        this.to3 = to3;
    }

    @Override
    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();

//        if (cvPath.getFileSize() == 0) {
//            errors.add("file", new ActionMessage("error.file.required"));
//        } else if (!cvPath.getContentType().equals("application/msword")
//                || !cvPath.getContentType().equals("application/pdf")
//                || !cvPath.getContentType().equals("text/plain")
//                || !cvPath.getContentType().equals("application/vnd.oasis.opendocument.text ")) {
//
//            errors.add("file", new ActionMessage("error.file.type"));
//        } else if (cvPath.getFileSize() > 20971520) {
//
//            errors.add("file", new ActionMessage("error.file.size"));
//        }
//
        if (getGender().equals("-1")) {
            errors.add("gender", new ActionMessage("error.gender"));
        }

        if (getFirstName().equals("") || getFirstName().length() <= 1) {
            errors.add("fname", new ActionMessage("error.fname"));
        }
        if (getMiddleName().equals("") || getMiddleName().length() <= 1) {
            errors.add("mname", new ActionMessage("error.mname"));
        }
        if (getLastName().equals("") || getLastName().length() <= 1) {
            errors.add("lname", new ActionMessage("error.lname"));
        }
        if (getBd().equals("") || getBd().length() <= 7) {
            errors.add("bd", new ActionMessage("error.bd"));
        }
        if (getPlaceOfBirth() == -1) {
            errors.add("pob", new ActionMessage("error.pob"));
        }
//        if (getMilitaryStatus().equals("-1")) {
//            errors.add("ms", new ActionMessage("error.ms"));
//        }
        if (getMaritalStatus().equals("-1")) {
            errors.add("mars", new ActionMessage("error.mars"));
        }
        if (getChildren() == -1) {
            errors.add("ch", new ActionMessage("error.ch"));
        }
        if (!getNatid().equals("") || getNatid().matches("/^[0-9]{9}[vVxX]$/")) {
            errors.add("nid", new ActionMessage("error.nid"));
        }
        if (getAdd1().equals("") || getAdd1().length() <= 1) {
            errors.add("add1", new ActionMessage("error.add1"));
        }

        if (getCountry().equals("-1")) {
            errors.add("country", new ActionMessage("error.country"));
        }
        if (getCity().equals("") || getCity().length() <= 1) {
            errors.add("city", new ActionMessage("error.city"));
        }
        if (getPhone().equals("") || getPhone().length() <= 1) {
            errors.add("phone", new ActionMessage("error.phone"));
        }
        if (getMob().equals("") || getMob().length() <= 1) {
            errors.add("mob", new ActionMessage("error.mob"));
        }
        if (getLevOfEd() == -1) {
            errors.add("level", new ActionMessage("error.level"));
        }
        if (getUniversity() == -1) {
            errors.add("uni", new ActionMessage("error.uni"));
        }
        if (getGrad() == -1) {
            errors.add("grad", new ActionMessage("error.grad"));
        }
        if (getGradYear().equals("-1")) {
            errors.add("year", new ActionMessage("error.year"));
        }
        if (getFieldOfStudy() == -1) {
            errors.add("study", new ActionMessage("error.study"));
        }
        if (getYearsOfExp() == -1) {
            errors.add("exp", new ActionMessage("error.exp"));
        }
        if (getCareer() == -1) {
            errors.add("career", new ActionMessage("error.career"));
        }
        if (getCompName1().equals(" ") || getCompName1().length() < 1) {
            setCompName1(" ");
        }
        if (getCompName2().equals(" ") || getCompName2().length() < 1) {
            setCompName2(" ");
        }
        if (getCompName3().equals(" ") || getCompName3().length() < 1) {
            setCompName3(" ");
        }
        if (getPos1().equals(" ") || getPos1().length() < 1) {
            setPos1(" ");
        }
        if (getPos2().equals(" ") || getPos2().length() < 1) {
            setPos2(" ");
        }
        if (getPos3().equals(" ") || getPos3().length() < 1) {
            setPos3(" ");
        }
        if (getFrom1().equals(" ") || getFrom1().length() < 1) {
            setFrom1(" ");
        }
        if (getFrom2().equals(" ") || getFrom2().length() < 1) {
            setFrom2(" ");
        }
        if (getFrom3().equals(" ") || getFrom3().length() < 1) {
            setFrom3(" ");
        }
        if (getTo1().equals(" ") || getTo1().length() < 1) {
            setTo1(" ");
        }
        if (getTo2().equals(" ") || getTo2().length() < 1) {
            setTo2(" ");
        }
        if (getTo3().equals(" ") || getTo3().length() < 1) {
            setTo3(" ");
        }

        return errors;

    }
}
